#include <iostream>
#include <cstdio>
using namespace std;
char t1[1024],t2[1024],t3[1024];
char password[26];
int abc[26];
int main()
{
    freopen("spy.in","r",stdin);
	freopen("spy.out","w",stdout);
	scanf("%s%s%s",t1,t2,t3);
    for(int i=0;t1[i]!=0;i++)
    {
        if(password[t1[i]-'A']!=0)
            if(password[t1[i]-'A']!=t2[i])
            {
                printf("Failed");
                return 0;
            }
        password[t1[i]-'A']=t2[i];
    }
    for(int i=0;i<26;i++)
    {
        if(password[i]==0)
        {
            printf("Failed");
            return 0;
        }
        abc[password[i]-'A']++;}
    for(int i=0;i<26;i++)
        if(abc[i]!=1)
        {
            printf("Failed");
            return 0;
        }
    for(int i=0;t3[i]!=0;i++)
        printf("%c",password[t3[i]-'A']);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

